package servlet;

import dbOperation.DbDelete;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by v on 17-5-23.
 */
@WebServlet(name = "DeleteServlet",value = "/DeleteServlet")
public class DeleteServlet extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException{
        int id;

        try {
            id=Integer.parseInt(req.getParameter("id"));
        }catch (Exception ex){
            id=-1;
        }

        if(DbDelete.delete(id)){
            resp.sendRedirect("/accept/delete.jsp?page="+req.getParameter("page"));
        }else {
            resp.sendRedirect("/exception/delete.jsp?page="+req.getParameter("page"));
        }

    }
}
